<template>
	<view>
		<baseForm :column.sync="column" @submitFun="submitFun" @changeColumn="changeColumn" :submitStatus="submitDisable"
		 :button="button"></baseForm>
		<progressBox :auditVos="auditVos" dictcode="dict_audit_status"></progressBox>
		<view class="buttons" v-if="getApprovalShow('applyStatus')">
			<button size="mini" class="middleButton" @click="pass('调代课', itemData)">通过</button>
			<button size="mini" class="middleButton" @click="unpass('调代课', itemData)">不通过</button>
		</view>
	</view>
</template>

<script>
	import baseForm from '@/wxcomponents/form/form.vue';
	import formMixins from '@/libs/formMixins.js';
	import {
		format
	} from '@/libs/common.js';
	import login from '@/libs/login.js';
	import dictMixins from '@/libs/dictMixins.js';
	import progressBox from '@/wxcomponents/commonLayout/progressLevel.vue';
	import approvalMixins from '@/libs/approvalMixins.js'
	export default {
		mixins: [formMixins, dictMixins, approvalMixins],
		data() {
			let self = this;
			return {
				itemData: '',
				auditVos: "",
				button: {
					hide: true
				},
				column: [{
							label: '停课起始日期',
							name: 'suspendStart',
							type: 'picker',
							mode: 'date',
							disabled: true,
							required: true,
							value: format('YY-mm-dd', new Date()),
							start: format('YY-mm-dd', new Date()),
							text: format('YY-mm-dd', new Date())
						},
						{
							label: '停课结束日期',
							name: 'suspendEnd',
							type: 'picker',
							mode: 'date',
							disabled: true,
							required: true,
							value: '',
							start: format('YY-mm-dd', new Date()),
							text: '请选择'
						},
						{
							label: '停课天数',
							name: 'suspendDay',
							type: 'normalInput',
							disabled: true,
							required: true,
							value: ''
						},
						{
							label: '停课年级',
							name: 'grade',
							type: 'picker',
							mode: 'selector',
							required: true,
							disabled: true,
							value: '',
							text: '请选择',
							range: self.findOneDictList('18000')
						},
						{
							label: '停课专业',
							name: 'majorName',
							type: 'normalInput',
							required: true,
							disabled: true,
							value: '',
							text: '请选择',
							range: []
						},
						{
							label: '停课班级',
							name: 'className',
							type: 'normalInput',
							mode: 'selector',
							disabled: true,
							required: true,
							value: '',
							text: '请选择',
				
							range: []
						},
						{
							label: '停课原因',
							name: 'suspendReason',
							type: 'normalInput',
							disabled: true,
							required: true,
							value: ''
						}
					],
				
			};
		},
		async onLoad(option) {
			this.itemData = JSON.parse(option.data);
			this.getDetail();
		},

		methods: {
			async getDetail() {
				let self = this;
				let caseMap = [{
						condition() { // 详情
							return self.itemData.detailType == 'detail'
						},
						async func() {
							let resp = await self.$http.get({
								url: `/edu/wechat/classCourseChange/detail/${self.itemData.id}`
							});
							self.assignFormDataToViewModel(resp.result, self.column);
							self.auditVos = resp.result.auditVoList;

						}
					},
					{
						condition() { // 审批
							return self.itemData.detailType == 'approval'
						},
						async func() {
							let resp = await self.$http.get({
								url: `/edu/wechat/classCourseChange/detail/${self.itemData.id}`
							});
							self.assignFormDataToViewModel(resp.result, self.column);
							self.auditVos = resp.result.auditVoList;

						}
					},
				]
				let findOne = caseMap.filter(item => {
					return item.condition()
				})[0]
				console.log(findOne)
				if (!findOne) {
					alert(`getDetail方法出错`)
				}
				findOne.func();
			}
		},

		components: {
			baseForm,
			progressBox
		},
		
		watch: {
			
		}
	};
</script>

<style></style>
